﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 纺织贸易管理系统;

namespace BLL
{
    public  class 销售客诉BLL
    {
        public  static void 审核通过(string danhao)
        {
            var doc = Connect.dbcontext.Queryable<CustomerComplaints>().First (x => x.DocNum == danhao);
            var danju = new DanjuTable()
            {
                ksbh = doc.SupplierNum,
                ksmc = doc.SupplierName,
                Qiankuan = "欠款",
                Hanshui = "含税",
                je = doc.ComplaintsMoney,
                totalmoney = 0,
                djlx = DanjuLeiXing.销售客诉单,
                dh = doc.DocNum
            };
            财务BLL.减少应收款(danju);
            来往明细BLL.增加来往记录(danju);
            Connect.dbcontext.Updateable(doc).ExecuteCommand();
        }
        public static void 反审核(string danhao)
        {
            var doc = Connect.dbcontext.Queryable<CustomerComplaints>().First(x => x.DocNum == danhao);
            var danju = new DanjuTable()
            {
                ksbh = doc.SupplierNum,
                ksmc = doc.SupplierName,
                Qiankuan = "欠款",
                Hanshui = "含税",
                je = doc.ComplaintsMoney,
                totalmoney = 0,
                djlx = DanjuLeiXing.销售客诉单,
                dh = doc.DocNum
            };
            财务BLL.增加应付款(danju);
            来往明细BLL.删除来往记录(danju);
            Connect.dbcontext.Updateable(doc).ExecuteCommand();
        }
    }
}
